#define  _CRT_SECURE_NO_WARNINGS


#include<stdio.h>
#include<string.h>

char* removeDuplicates(char* s) {
    int len = strlen(s);
    char* stack = (char*)malloc(sizeof(char) * (len + 1));
    int top = 0;
    for (int i = 0; i < len; i++)
    {
        if (top > 0 && s[i] == stack[top - 1])
            top--;
        else
            stack[top++] = s[i];
    }
    stack[top] = 0;
    return stack;
}

int main()
{
    char str[] = "bcaac";
    char string[100] = { 0 };
    strcpy(string, removeDuplicates(str));
    puts(string);
    return 0;
}